#include <stdio.h>
main()
{	    	  	 	 	 
    static int day_tab[2][13]={	    	  	 	 	 
        {0,31,28,31,30,31,30,31,31,30,31,30,31},
        {0,31,29,31,30,31,30,31,31,30,31,30,31}};
    int y,m,d;
    scanf("%d%d%d",&y,&m,&d);
    printf("%d\n",day_of_year(day_tab,y,m,d));
}	    	  	 	 	 
day_of_year(day_tab,year,month,day)
    int day_tab[][13];
    int year,month,day;
{	    	  	 	 	 
    int i,j;
    i=(year%4==0&&year%100!=0)||year%400==0;
    for(j=1;j<month;j++)
        day+=day_tab[i][j];
    return day;
}	    